#!/usr/bin/env python

import sys, os

check_lxml = True
sourcesDir = "source/"
scriptsDir = "scripts/"

if not os.path.isdir(scriptsDir):
    os.mkdir(scriptsDir)

if check_lxml:
    try:
        import lxml
    except:
        print "The lxml library must be installed to use xmlTools. Get it from http://codespeak.net/lxml"
        print "Installation not complete"
        sys.exit(1)

sourceFiles = os.popen2("ls "+ sourcesDir + "*.py")[1].read().splitlines()
for sourceFile in sourceFiles:
    newName = "xmlTools." + sourceFile.split("/").pop().split(".")[0]
    os.popen2("cp " + sourceFile + " " + scriptsDir + newName)
    os.popen2("chmod 755 " + scriptsDir + newName)
